<template>
	<view>
		<view class="pay-context" style="display: flex; justify-content: center; align-items: center;">
			<view style="text-align: center;">
				<image width="180rpx" height="160rpx" src="../../static/pay-success.png" mode="widthFix"></image>
				<view>
					<view>
						<text style="font-size: 46rpx; font-weight: 700;">支付成功</text>
					</view>
					<view>
						<text>即将跳转到首页{{countDown}}s...</text>
					</view>
					<view style="margin-top: 10rpx;">
						<button @click="toIndex()" style="width: 200rpx; height: 80rpx; line-height: 80rpx; background-color: #00cd30;">立即跳转</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isFinish:true,
				countDown:10,
				timer: null // 定时器
			}
		},
		mounted() {
			this.startCountDown();
		},
		methods: {
			startCountDown(){
				this.timer = setInterval(() => {
					if (this.countDown > 0) {
						this.countDown--;
					} 
					else {
						clearTimeout(this.timer);
						uni.switchTab({
							url:'/pages/index/index'
						})
					}
				}, 1000);
			},
			toIndex(){
				clearTimeout(this.timer);
				uni.switchTab({
					url:'/pages/index/index'
				})
			}
			
		}
	}
</script>

<style>

</style>
